﻿using B.R.RabbitRoot.Domain;
using B.R.RabbitRoot.ErrorCode;
using B.R.RabbitRoot.Infrastructure.Interface;
using B.R.RabbitRoot.Read.API.Applications.Commands.SourceInfoCommands;
using MediatR;

namespace B.R.RabbitRoot.Read.API.Applications.CommandHandlers.SourceInfoCommandHandlers
{
    /// <summary>
    ///  商品名称命令处理
    /// </summary>
    public class productQuerycommandHandler : IRequestHandler<productQueryCommand, APIResult<List<product>>>
    {
        private readonly IBaserepository<product> productRepsitoty;

        public productQuerycommandHandler(IBaserepository<product> productRepsitoty)
        {
            this.productRepsitoty = productRepsitoty;
        }
        /// <summary>
        /// 商品名称命令处理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<APIResult<List<product>>> Handle(productQueryCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<product>> result=new APIResult<List<product>>();
            result.Code=ResultCode.显示成功;
            result.Message = ResultCode.显示成功.ToString();
            result.Data=productRepsitoty.GetAll().ToList();
            return await Task.FromResult(result);
        }
    }
}
